import { createRouter, createWebHistory } from 'vue-router';
import Login from '../views/Login.vue';
import Dashboard from '../views/Dashboard.vue';
import Orders from '../components/Orders.vue';
import OrderDetails from '../components/OrderDetails.vue';
import ErrorPage from '../components/ErrorPage.vue';

const routes = [
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/dashboard',
        name: 'Dashboard',
        component: Dashboard
    },

    {
        path: '/orders', // 更新后的路径
        name: 'Orders',
        component: Orders
    },
    {
        path: '/error',  // 错误页面路由
        name: 'ErrorPage',
        component: ErrorPage
    },
    {
        path: '/orders/:orderNumber',  // 修改这里：动态路由接收订单号
        name: 'OrderDetails',
        component: OrderDetails,
        props: true,  // 允许把路由参数作为 prop 传递到组件
    }
];

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes
});

export default router;
